﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Lottery.Herper;

namespace Lottery.MediaData.UI {
    /// <summary>
    /// 模拟开奖
    /// </summary>
    public partial class SimulationForm : Form {
        public SimulationForm() {
            InitializeComponent();

            input.JumpTo = buttonOK;

            this.SetDialogStyle();
        }

        private void buttonOK_Click(object sender, EventArgs e) {
            for (int i = 0; i < input.Count; i++) {
                var item = input[i];
                if (item.Text == string.Empty) {
                    item.Focus();
                    this.ShowInfo(string.Format("第 {0} 场奖号没有输入", i + 1));
                    return;
                }
            }

            Numbers = new string[14];
            for (int i = 0; i < input.Count; i++) {
                Numbers[i] = input[i].Text;
            }

            DialogResult = DialogResult.OK;
        }

        /// <summary>
        /// 奖号
        /// </summary>
        public string[] Numbers { get; set; }

        private void SimulationForm_Shown(object sender, EventArgs e) {
            for (int i = 0; i < Numbers.Length; i++) {
                input[i].SelectedIndex = input[i].Items.IndexOf(Numbers[i] ?? string.Empty);
            }
        }
    }
}
